package com.novunda.platform.web.page;

import com.novunda.platform.AbstractWebTest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class CommonLoginPage {
    private String username;
    private String password;
    private final WebDriver driver;
    private final AbstractWebTest webTest;

    public CommonLoginPage(AbstractWebTest webTest, WebDriver driver) {
        this.webTest = webTest;
        this.driver = driver;
    }

    public void invoke(String username, String password) throws InterruptedException {
        driver.get("http://localhost/login");

        WebElement changeBtn = driver.findElement(By.cssSelector("button.pswbt"));
        changeBtn.click();

        Thread.sleep(500);

        WebElement form1 = driver.findElement(By.cssSelector("form.login-form"));
        form1.findElement(By.cssSelector("input[name=username]")).sendKeys(username);
        form1.findElement(By.cssSelector("input[name=password]")).sendKeys(password);
        form1.findElement(By.cssSelector("button[type=submit]")).click();

    }

}